package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.base.BaseDAO;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.UserInfoDAO;
import com.atguigu.entity.UserInfo;
import com.atguigu.service.UserInfoService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @PACKAGE_NAME: com.atguigu.service.impl
 * @CLASSNAME: UserInfoServiceImpl
 * @AUTHOR: zhangsan
 * @DATE: 2024/4/27 10:59
 * @SINCE 17.0.7
 * @DESCRIPTION: UserInfoServiceImpl
 */
@Service(interfaceClass = UserInfoService.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class UserInfoServiceImpl extends BaseServiceImpl<UserInfo> implements UserInfoService {

    @Resource
    private UserInfoDAO userInfoDAO;

    @Override
    protected BaseDAO<UserInfo> getEntityDAO() {
        return userInfoDAO;
    }

    /**
     * 通过手机号,查询用户
     *
     * @param phone
     * @return
     */
    @Override
    public UserInfo getByPhone(String phone) {
        if (null == phone || phone.isEmpty()) {
            return null;
        }
        UserInfo userInfo = userInfoDAO.getByPhone(phone);
        return userInfo;
    }
}
